package com.cn.zpark.controller;

import com.cn.zpark.beans.User;
import com.cn.zpark.service.IFindUserService;
import com.cn.zpark.service.impl.FindUserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @PackageName: com.cn.zpark.controller
 * @ClassName: FindUserTenServletController
 * @Description:
 * @author: RZS
 * @date: 2022/4/27  20:29
 */
@WebServlet("/find_user_ten.do")
public class FindUserTenServletController extends HttpServlet {

    // 定义业务层接口对象
    private IFindUserService userService = new FindUserServiceImpl();

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取请求参数
        // 调用业务层接口查询数据
        List<User> userTen = userService.findUserTen();
        // 将数据绑定到请求域对象中
        request.setAttribute("users", userTen);
        // 调用View展示数据（转发给JSP展示数据）
        request.getRequestDispatcher("jsp/demo01.jsp").forward(request, response);
    }
}

